Lock Screen 0.3: Keep folks from using your computer. NOT SECURE!
Copyright (C) 2000 Gordon Worley.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
For a copy of the GNU General Public License, visit <http://www.gnu.org/> or write to the Free Software Foundation, Inc., 59 Temple Place--Suite 330, Boston, MA 02111-1307, USA.
To contact me, please visit my Web site at <http://www.rbisland.cx/> or e-mail me at <redbird@rbisland.cx>.
History:
0.3 - Added a show_background function to counteract the effects of hide_background. A few cravaets mentioned below.
0.2 - Added a hide_background function that hides all of the background processes, keeping prying eyes from prying.
0.1 - Added Keychain support. Has some problems, though. Check the documentation and comments for info.
0.0 - Initial release.
*)
--I can't say this enough: THIS SCRIPT IS NOT SECURE!!!!!! It is very easy to subvert this system, but will keep casual onlookers from seeing anything.
--Force quiting gets around this program. Fortunately for you, most people don't know how to do it (command-option-esc).
on run
set the_response to display dialog "Lock Screen 0.3. What do you want to do to your screen? " buttons {"Nothing", "Manual Lock", "Auto Lock"} default button 2
if the_response's button returned is "Manual Lock" then
my manual_lock()
else if the_response's button returned is "Auto Lock" then
my auto_lock()
else
return
end if
end run
on manual_lock()
set the_password to display dialog "Enter password to use to lock this computer." default answer "" buttons {"Okay"} default button 1 with icon 1 --enter the password you want here. remember: NOT SECURE!!!!
set the_password to the_password's text returned --put the password in this variable
my hide_background()
set keep_locked to true
repeat while keep_locked is true --keep looping until corrent answer is entered
set entered_password to display dialog "Please enter password to access this computer." default answer "" buttons {"Okay"} default button 1 with icon 2
--I could really use some bullet text so that people can't see your password as you type it. Any ideas?
if entered_password's text returned is the_password then --not secure either
set keep_locked to false
else
display dialog "Oops, that's not it. You need to enter the correct password to access this computer." buttons {"All right..."} default button 1 with icon 0
end if
end repeat
my show_background()
end manual_lock
on auto_lock()
my hide_background()
--this is experimental and has problems. explained below
set keep_locked to true
repeat while keep_locked is true
set the_password_response to display dialog "Please enter password to access this computer." default answer "" buttons {"Okay"} default button 1 with icon 2
set the_password to the_password_response's text returned
tell application "Keychain Scripting"
try
unlock with password the_password --if given the wrong password once, it will not work again, even given the correct password, until the correct password is manuly entered into Kyechain Access. Don't know what causes this. Any ideas?
lock
set keep_locked to false
on error
display dialog "Oops, that's not it. You need to enter the correct password to access this computer." buttons {"All right..."} default button 1 with icon 0
end try
end tell
end repeat
my show_background()
end auto_lock
on hide_background()
--thanks to Apple for the code I used to make this (I just made a few modification to what was in one of the Speakable Items scripts).
tell application "Finder"
--every visible background process. The Finder will never be in this list
set all_processes to (every process whose visible is true and frontmost is false)
if all_processes ≠ {} then
repeat with a_process in all_processes
set the visible of a_process to false
end repeat
end if
--make the Finder invisible
if ((the frontmost of application "Finder" is false) and (the visible of application "Finder" is true)) then
set the visible of application "Finder" to false
end if
end tell
end hide_background
on show_background()
(*
As with anything, this has a few problems:
- Application Switcher doesn't update when the processes are made visible (they look like they're hidden)
- I had to add a try structure because many processes not listed in the Application Switcher can't be made visible (but I guess they can be made invisible ;-))
Sorry, these are Apple's fault. There are probably more, I just don't know about them yet.
*)
tell application "Finder"
--every hidden background process. The Finder will never be in this list
set all_processes to (every process whose visible is false and frontmost is false)
if all_processes ≠ {} then
repeat with a_process in all_processes
try
set the visible of a_process to true
on error
--pass
end try
end repeat
end if
--make the Finder visible
if ((the frontmost of application "Finder" is false) and (the visible of application "Finder" is false)) then